package com.rm.zeyou.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rm.zeyou.entity.AgreementConfig;
import com.rm.zeyou.entity.DictConfig;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.AgreementConfigService;
import com.rm.zeyou.service.DictConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 系统参数配置 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:08
 */
@Api(tags = "系统参数")
@RestController
@RequestMapping("/api/dictConfig")
public class DictConfigController {
    @Resource
    private DictConfigService dictConfigService;
    @Resource
    private AgreementConfigService agreementConfigService;

    @ApiOperation( "用户协议")
    @GetMapping("userAgreement")
    public ApiRestResponse<String> userAgreement() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "user_agreement"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "隐私政策")
    @GetMapping("privacyPolicy")
    public ApiRestResponse<String> privacyPolicy() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "privacy_policy"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "预约须知")
    @GetMapping("reservationInstructions")
    public ApiRestResponse<String> reservationInstructions() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "reservation_instructions"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation("使用协议")
    @GetMapping("useTerms")
    public ApiRestResponse<String> useTerms() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "use_terms"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "责任声明")
    @GetMapping("disclaimer")
    public ApiRestResponse<String> disclaimer() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "disclaimer"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation("号码保护")
    @GetMapping("numberProtection")
    public ApiRestResponse<String> numberProtection() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "number_protection"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation("会员卡协议")
    @GetMapping("memberAgreement")
    public ApiRestResponse<String> memberAgreement() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "member_agreement"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "操作流程")
    @GetMapping("procedure")
    public ApiRestResponse<String> procedure() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "procedure"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "公众号名")
    @GetMapping("officialName")
    public ApiRestResponse<String> officialName() {
        DictConfig userAgreement = dictConfigService.getOne(new LambdaQueryWrapper<DictConfig>().eq(DictConfig::getCode, "official_name"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "公众号二维码")
    @GetMapping("officialQrcode")
    public ApiRestResponse<String> officialQrcode() {
        DictConfig userAgreement = dictConfigService.getOne(new LambdaQueryWrapper<DictConfig>().eq(DictConfig::getCode, "official_qrcode"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "提现说明")
    @GetMapping("payoutIllustrate")
    public ApiRestResponse<String> payoutIllustrate() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "payout_illustrate"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation("下载地址")
    @GetMapping("downAddress")
    public ApiRestResponse<Map<String,String>> downAddress() {
        return dictConfigService.downAddress();
    }

    @ApiOperation( "客服热线")
    @GetMapping("customerServiceTel")
    public ApiRestResponse<String> customerServiceTel() {
        DictConfig userAgreement = dictConfigService.getOne(new LambdaQueryWrapper<DictConfig>().eq(DictConfig::getCode, "customer_service_tel"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "logo")
    @GetMapping("logo")
    public ApiRestResponse<String> logo() {
        DictConfig userAgreement = dictConfigService.getOne(new LambdaQueryWrapper<DictConfig>().eq(DictConfig::getCode, "logo"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

    @ApiOperation( "软件使用许可协议")
    @GetMapping("softwareAgreement")
    public ApiRestResponse<String> softwareAgreement() {
        AgreementConfig userAgreement = agreementConfigService.getOne(new LambdaQueryWrapper<AgreementConfig>().eq(AgreementConfig::getCode, "software_agreement"));
        return ApiRestResponse.success(userAgreement.getValue());
    }

}
